package com.briup.day3;

import java.util.Scanner;

public class Hello {

    // 注意类名必须为 Main, 不要有任何 package xxx 信息
    public static boolean lexicographically(String[] array) {
        for (int i = 0; i < array.length-1; i++) {
            if (array[i].compareTo(array[i+1]) > 0) {
                return false;
            }
        }
        // 3 + 2
        // 0011
        // 0010
        // 0101

        // 0011
        //^0010
        // 0001  -- sum - A

        // 0011
        // 0010
        //&0010
        // 0100  -- carry - B

        // 0001
        // 0100
        //^0101

        return true;
    }

    public static boolean lengths(String[] array) {
        int i = 0;
        for(; i < array.length-1; i++) {
            int len1 = array[i].length();
            int len2 = array[i+1].length();

            if(len1 > len2) {
                break;
            }
        }
        if(i == array.length-1) {
            return true;
        }

        return false;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = in.next();
        }
        if(lexicographically(s) && lengths(s)) {
            System.out.println("both");
        }else if(lexicographically(s)) {
            System.out.println("lexicographically");
        }else if(lengths(s)) {
            System.out.println("lengths");
        }else {
            System.out.println("none");
        }


    }
}
